package com.example.my.meila.view.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.my.meila.R;
import com.example.my.meila.common.image.ImageLoader;
import com.example.my.meila.constast.Constast;
import com.example.my.meila.entity.Paihangbang;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by zhanghao on 2016/10/31.
 */
public class PaihangbangBottomAdapter extends RecyclerView.Adapter<PaihangbangBottomAdapter.MainViewholder> {


    private Context context;
    private List<Paihangbang.DataBean.AdvisersBean.ListBean> data;

    public PaihangbangBottomAdapter(Context context, List<Paihangbang.DataBean.AdvisersBean.ListBean> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public MainViewholder onCreateViewHolder(ViewGroup parent, int viewType) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        View view = inflater.inflate(R.layout.item_recyclerview_paihangbang_bottom, null);
        MainViewholder holder = new MainViewholder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(MainViewholder holder, int position) {
        ImageLoader.getInstance().transformationsImage(context, Constast.PUBLIC_URL + data.get(position).getAvatar(), holder.ivPaihangbangBottom);
        holder.tvPaihangbangAdvisersIntro.setText(data.get(position).getRater_intro());
        holder.tvPaihangbangAdvisersName.setText(data.get(position).getNickname());
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    public class MainViewholder extends RecyclerView.ViewHolder {
        @BindView(R.id.iv_paihangbang_bottom)
        ImageView ivPaihangbangBottom;
        @BindView(R.id.tv_paihangbang_advisers_name)
        TextView tvPaihangbangAdvisersName;
        @BindView(R.id.tv_paihangbang_advisers_intro)
        TextView tvPaihangbangAdvisersIntro;

        public MainViewholder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
